package com.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RedirectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getSession().setAttribute("sessionMsg", "这是重定向通过Session带来的数据");
        // 重定向路径必须拼接项目上下文路径
        response.sendRedirect(request.getContextPath() + "/target.jsp");
    }
}
